package com.restaurant.application.indexes.couponlist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.coupon.Coupon;
import com.restaurant.application.indexes.couponlist.mysql.CouponListCriteria;

/**
 * @author Administrator
 */
public class AssistCouponListDesc extends UnitDescription {

    public static void main(String[] args) {
        getUnitDescription().run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    private static UnitDescription getUnitDescription() {
        UnitDescription desc = UnitDescription.basicUnit(AssistCouponList.class, null);
        desc.addUiFunction("search", CouponListCriteria.class.getName());
        return desc;
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("CouponList")
                .withPackageName(AssistCouponListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("couponUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(Coupon.class.getName())
                        .addContribution(getSQLColumn("couponManageUid", DataTypes.STRING, "优惠券管理uid", 255))
                        .addContribution(getSQLColumn("number", DataTypes.STRING, "优惠券编号", 255))
                        .addContribution(getSQLColumn("endTime", DataTypes.LONG, "服务期限时间", 20))
                        .addContribution(getSQLColumn("type", DataTypes.STRING, "优惠券类型", 255))
                        .addContribution(getSQLColumn("modality", DataTypes.STRING, "优惠券形式", 255))
                        .addContribution(getSQLColumn("fullMoney", DataTypes.DOUBLE, "满多少金额", 255))
                        .addContribution(getSQLColumn("minusMoney", DataTypes.DOUBLE, "减多少金额", 255))
                        .addContribution(getSQLColumn("shopUid", DataTypes.STRING, "店铺Uid", 255))
                        .addContribution(getSQLColumn("shopName", DataTypes.STRING, "店铺名称", 255))
                        .addContribution(getSQLColumn("remarks", DataTypes.STRING, "备注（注意事项）", 255))
                        .addContribution(getSQLColumn("state", DataTypes.STRING, "是否过期", 255))
                        .addContribution(getSQLColumn("id", DataTypes.STRING, "优惠券id", 255))
                        .addContribution(getSQLColumn("createTime", DataTypes.LONG, "创建时间", 20))
                        .addContribution(getSQLColumn("modifyTime", DataTypes.LONG, "修改时间", 20))
                        .addContribution(getSQLColumn("customerId", DataTypes.STRING, "领券客户Id", 255))
                        .addContribution(getSQLColumn("customerUid", DataTypes.STRING, "领券客户Uid", 255))
                        .addContribution(getSQLColumn("customerName", DataTypes.STRING, "领券客户名称", 255))
                        .addContribution(getSQLColumn("phone", DataTypes.STRING, "领券联系方式", 255))
                        .addContribution(getSQLColumn("qrCodeUrl", DataTypes.STRING, "二维码地址", 255))
                        .addContribution(getSQLColumn("qrCodeUid", DataTypes.STRING, "二维码Uid", 255))
                        .addContribution(getSQLColumn("couponState", DataTypes.STRING, "是否使用", 255))
                        .addContribution(getSQLColumn("currentCustomerId", DataTypes.STRING, "当前客户Id", 255))
                        .addContribution(getSQLColumn("currentCustomerUid", DataTypes.STRING, "当前客户Uid", 255))
                        .addContribution(getSQLColumn("currentCustomerName", DataTypes.STRING, "当前客户名称", 255))
                        .addContribution(getSQLColumn("currentPhone", DataTypes.STRING, "当前联系方式", 255))
                        .addContribution(getSQLColumn("usedCustomerId", DataTypes.STRING, "当前客户Id", 255))
                        .addContribution(getSQLColumn("usedCustomerUid", DataTypes.STRING, "当前客户Uid", 255))
                        .addContribution(getSQLColumn("usedCustomerName", DataTypes.STRING, "当前客户名称", 255))
                        .addContribution(getSQLColumn("usedPhone", DataTypes.STRING, "当前联系方式", 255))
                        .addContribution(getSQLColumn("usedTime", DataTypes.LONG, "使用时间", 20))
                        .addContribution(getSQLColumn("userId", DataTypes.STRING, "客户Id", 255))
                        .addContribution(getSQLColumn("userUid", DataTypes.STRING, "客户Uid", 255))
                        .addContribution(getSQLColumn("userName", DataTypes.STRING, "客户名称", 255))
                );
    }

    private static SQLColumn getSQLColumn(String name, DataTypes type, String label, Integer width) {
        return new SQLColumn().withName(name).withType(type).withLabel(label).withWidth(width);
    }
}
